#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Box.H>
// clear && g++ 输入框和标签.cpp -o hello_fltk `fltk-config --cxxflags --ldflags` && ./hello_fltk
class MyWindow : public Fl_Window
{
    Fl_Input *input;
    Fl_Box *label;

public:
    MyWindow(int W, int H, const char *l = 0) : Fl_Window(W, H, l)
    {
        input = new Fl_Input(100, 50, 200, 30, "Type something...");
        label = new Fl_Box(100, 100, 200, 30, "Label will update...");
        label->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE);

        input->when(FL_WHEN_CHANGED);
        input->callback((Fl_Callback *)input_cb, this);

        end();
        show();
    }

    static void input_cb(Fl_Widget *, void *w)
    {
        MyWindow *window = (MyWindow *)w;
        window->label->label(window->input->value());
    }
};

int main(int argc, char **argv)
{
    MyWindow window(400, 200, "FLTK Input Example");
    return Fl::run();
}